/******************************************************************************
 * Copyright (C) ShenZhen Powerdata Information Technology Co.,Ltd
 * All Rights Reserved.
 * 本软件为深圳市博安达信息技术股份有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、
 * 复制、修改或发布本软件.
 *****************************************************************************/

package com.szboanda.business.relevance.config.controller;

import com.github.pagehelper.PageInfo;
import com.szboanda.beijing.pure.BaseBusinessController;
import com.szboanda.business.relevance.config.exception.RelevanceConfigException;
import com.szboanda.business.relevance.config.service.IRelevanceConfigService;
import com.szboanda.platform.common.utils.Toolkit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @title:      关联引擎业务配置_控制器
 * @fileName:   RelevanceConfigController.java
 * @description:
 * @copyright:  PowerData Software Co.,Ltd. Rights Reserved.
 * @company:    深圳市博安达信息技术股份有限公司
 * @author:     原晋川
 * @date:       2019-09-20 14:51
 * @version:    V1.0
 */
 
@Controller
@RequestMapping("/business/relevance/config/relevanceconfigcontroller")
public class RelevanceConfigController extends BaseBusinessController {

    /**
     * 注入处理业务接口
     */
    @Autowired
    private IRelevanceConfigService relevanceConfigService;
    
    
    /**
     * 跳转到【关联引擎业务配置】查询页面
     * @return
     * @throws RelevanceConfigException
     */
    @RequestMapping("/list")
    public String getListPageName() throws RelevanceConfigException {
        this.setToken();
        return "/business/relevance/config/relevanceconfiglist";
    }

    /**
     * 跳转到【关联引擎业务配置】新增页面
     * @return
     * @throws RelevanceConfigException
     */
    @RequestMapping("/add")
    public String getAddPageName(ModelMap mp) throws RelevanceConfigException {
        this.setToken();
        mp.put("XH_TEMP", Toolkit.getID());
        return "/business/relevance/config/relevanceconfigedit";
    }
	/**
     * 跳转到【关联引擎业务配置】编辑页面
     * @param xh 业务数据序号
     * @param mp 页面View的Model对象
     * @return
     * @throws RelevanceConfigException
     */
    @RequestMapping("/edit/{xh}")
    public String getEditPageName(@PathVariable String xh, ModelMap mp) throws RelevanceConfigException {
        this.setToken();
        mp.put("XH", xh);
        return "/business/relevance/config/relevanceconfigedit";
    }
	/**
     * 跳转到【关联引擎业务配置】视图页面
     * @param xh 业务数据序号
     * @param mp 页面View的Model对象
     * @return
     * @throws RelevanceConfigException
     */
    @RequestMapping("/detail/{xh}")
    public String getDetailPageName(@PathVariable String xh, ModelMap mp) throws RelevanceConfigException {
        this.setToken();
        mp.put("XH", xh);
        return "/business/relevance/config/relevanceconfigdetail";
    }
    
    /**
     * 查询【关联引擎业务配置】单条业务信息
     * @param    xh 业务数据序号
     * @return   返回某个业务Map信息
     * @throws RelevanceConfigException
     */
    @RequestMapping(value = "/detailData/{xh}")
    @ResponseBody
    public Map<String,Object> getDetailDataByXh(@PathVariable String xh) throws RelevanceConfigException {
        return relevanceConfigService.queryRelevanceConfigByXh(xh);
    }
    
   /**
    * 查询【关联引擎业务配置】业务信息
    * @param    params 业务集合
    * @return   返回某个业务Map信息
    * @throws RelevanceConfigException
    */
   @RequestMapping(value = "/queryRelevanceConfigs")
   @ResponseBody
   public PageInfo<Map<String, Object>> queryRelevanceConfigsInPage(@RequestBody Map<String, Object> params) throws RelevanceConfigException {
       int pageNum = getPageNum(params);//获取分页数
       int pageSize = getPageSize(params);//获取分页长度
       return relevanceConfigService.queryRelevanceConfigsInPage(pageNum, pageSize, params);
   }

    /**
     * 保存【关联引擎业务配置】业务信息
     * @param  params 业务Map集合
     * @return  返回操作标识符
     * @throws RelevanceConfigException
     */
    @RequestMapping(value = "/saveRelevanceConfig", method = { RequestMethod.POST })
    @ResponseBody
    public Map<String,Object> saveRelevanceConfig(@RequestBody Map<String, Object> params) throws RelevanceConfigException {
        if (!this.validToken(params)) {
            return null;
        }
//        ResDataModel<Map<String, Object>> result = ;
//        result.setToken(this.setToken());
        return relevanceConfigService.saveRelevanceConfig(params);
    }
    
     /**
     * 删除【关联引擎业务配置】业务信息
     * @param  params 业务集合
     * @return  返回操作标识符
     * @throws RelevanceConfigException
     */
    @RequestMapping(value = "/deleteRelevanceConfig", method = { RequestMethod.POST })
    @ResponseBody
    public Map<String,Object> deleteRelevanceConfig(@RequestBody Map<String, Object> params) throws RelevanceConfigException {
        if (!this.validToken(params)) {
            return null;
        }
        Map<String,Object> result = relevanceConfigService.deleteRelevanceConfig(params);
        return result;
    }
	
}
